package zuoye1;

import java.io.*;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        /*
        FileOutputStream fos=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw,true);
        System.out.println("请写入");
        Scanner scanner=new Scanner(System.in);
        while (true){
            String line=scanner.nextLine();
            if ("exit".equals(line)){
                break;
            }pw.println(line);
        }pw.close();

         */
        /*
        FileOutputStream fos=new FileOutputStream("pw.txt");//低级流创建文件
        OutputStreamWriter osw=new OutputStreamWriter(fos);//转换流字符转换字节
        BufferedWriter bw=new BufferedWriter(osw);//加个BUFF
        PrintWriter pw=new PrintWriter(bw,true);//换行输入
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入，单独输入exit退出");
        while (true){
            String line=scanner.nextLine();
            if ("exit".equals(line)){
                break;
            }pw.println(line);
        }
        pw.close();
        System.out.println("完毕");

 */

        FileOutputStream fos=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw);
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入，单独输入exit退出");
        while (true){
            String line=scanner.nextLine();
            System.out.println("------------------");
            if ("exit".equals(line)){
                break;
            }pw.println(line);
        }pw.close();
    }

}
